/*
 * p10652.cpp
 *
 *  Created on: 2013-6-3
 *      Author: zy
 */
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
const double PI = acos(-1.0);
int sig(double d)
{
	return fabs(d) < 1E-6 ? 0 : d < 0 ? -1 : 1;
}
struct Point
{
	double x, y;
	Point()
	{
	}
	Point(double x, double y) :
		x(x), y(y)
	{
	}
	void set(double x, double y)
	{
		this->x = x;
		this->y = y;
	}
	double mod()
	{//模
		return sqrt(x * x + y * y);
	}
	double mod_pow()
	{//模的平方
		return x * x + y * y;
	}
	Point friend operator -(Point a, Point b)
	{
		return Point(a.x - b.x, a.y - b.y);
	}
	Point friend operator +(Point a, Point b)
	{
		return Point(a.x + b.x, a.y + b.y);
	}
	bool operator <(const Point &p) const
	{
		return sig(x - p.x) != 0 ? x < p.x : sig(y - p.y) < 0;
	}
};

double cross(Point o, Point a, Point b)
{
	return (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);
}
double dot(Point &o, Point &a, Point &b)
{
	return (a.x - o.x) * (b.x - o.x) + (a.y - o.y) * (b.y - o.y);
}
int btw(Point &x, Point &a, Point &b)
{
	return sig(dot(x, a, b));
}
int g_cmp(const void *a, const void *b)
{
	int d = sig(((Point*) a)->y - ((Point*) b)->y);
	return d ? d : sig(((Point*) a)->x - ((Point*) b)->x);
}
//按x从小到大排序，向右走为合法
int graham(Point*p, int n, int*ch)
{
#define push(x)     ch[len ++]=x
#define pop()		len --
	sort(p, p + n);
	int len = 0, len0 = 1, i;
	for (i = 0; i < n; i++)
	{
		while (len > len0 && sig(cross(p[ch[len - 1]], p[ch[len - 2]], p[i]))
				<= 0)
			pop();
		push(i);
	}
	len0 = len;
	for (i = n - 2; i >= 0; i--)
	{
		while (len > len0 && sig(cross(p[ch[len - 1]], p[ch[len - 2]], p[i]))
				<= 0)
			pop();
		push(i);
	}
	return len - 1;
}
double area(Point*p, int num)
{
	double area = 0;
	double tmp;
	p[num] = p[0];
	for (int i = 0; i < num; i++)
	{
		tmp = p[i].x * p[i + 1].y - p[i].y * p[i + 1].x;
		area += tmp;
	}
	area /= 2.0;
	if (area < 0)
		area = -area;
	return area;
}
Point rotate(Point p, double radian)
{
	double c = cos(radian), s = sin(radian);
	p.set(p.x * c - p.y * s, p.y * c + p.x * s);
	return p;
}
int cnt;
Point p[610 * 4], q[610 * 4];
int c[610 * 4];
void getPoint(double x, double y, double w, double h, double ang)
{
	Point r[4], o;
	o.set(x, y);
	r[0].set(x + w / 2, y - h / 2);
	r[1].set(x + w / 2, y + h / 2);
	r[2].set(x - w / 2, y + h / 2);
	r[3].set(x - w / 2, y - h / 2);
	for (int i = 0; i < 4; i++)
		p[cnt++] = rotate(r[i] - o, -ang) + o;
}
int main()
{
	int T, n;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d", &n);
		cnt = 0;
		double recArea = 0;
		for (int i = 0; i < n; i++)
		{
			double x, y, w, h, j;
			scanf("%lf%lf%lf%lf%lf", &x, &y, &w, &h, &j);
			getPoint(x, y, w, h, j / 180 * PI);
			recArea += w * h;
		}
		n = graham(p, cnt, c);
		for (int i = 0; i < n; i++)
			q[i] = p[c[i]];
		double sumArea = area(q, n);
		printf("%0.1f \%\n", recArea / sumArea * 100);
	}
	return 0;
}
